


class MembarInterface:
    def __init__(self):
        self.url = 'http://47.108.206.100:8085'

    def get_auth_code(self, tel):
        method = 'get'
        url = self.url + '/sso/getAuthCode'
        payload = {'telephone': tel}
        return SendMethod.send_method(method=method, url=url, params=payload)

    def get_verify_code(self, tel):
        response = self.get_auth_code(tel)
        return GetKeyword.get_keyword(response, 'data')

    def register(self, body):
        method = 'post'
        url = self.url + '/sso/register'
        return SendMethod.send_method(method=method, url=url, data=body)

    def login(self, data):
        method = 'post'
        url = self.url + '/sso/login'
        return SendMethod.send_method(method=method, url=url, data=data)

    def get_token(self, body):
        response = self.login(body)
        token = GetKeyword.get_keyword(response, 'token')
        return {"Authorization": f'bearer {token}'}

    def get_info(self, body):
        method = 'get'
        url = self.url + '/sso/info'
        return SendMethod.send_method(method=method, url=url, data=body)


if __name__ == '__main__':
    m = MembarInterface()
    tel = '13628657183'
    password = '123456'
    username = 'tom123'
    # print(m.get_auth_code(tel))
    # print(m.get_verify_code(tel))
    # body = {
    #     "authCode": m.get_verify_code(tel),
    #     "password": password,
    #     "telephone": tel,
    #     "username": username,
    #
    # }
    # print(m.register(body))
    # body = {
    #     'username': username,
    #     'password': password
    # }
    # print(m.login(body))
    # print(m.get_token(body))

    body = {
        'name': username,
        'Authorization': 'bearereyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b20xMjMiLCJjcmVhdGVkIjoxNjg2NTUyMzg4Mzc4LCJleHAiOjE2ODcxNTcxODh9.xd52pSMR1LPmeVMT-fTQcQgrMS_OliE_gz3qtBZnWXRRpd5Z77HOt9OILTu7NdhZ9CRhpJnUNbRhYo79ds9b_Q'
    }
    print(m.get_info(body))
